//
//  DownloadDoneCell.m
//  MHO
//
//  Created by Hien NV on 6/19/14.
//  Copyright (c) 2014 maihoang. All rights reserved.
//

#import "DownloadDoneCell.h"
#import "Lib.h"


@interface DownloadDoneCell()
@property (weak, nonatomic) IBOutlet UIButton*  deleteButton;

@end

@implementation DownloadDoneCell

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setApp:(Application *)app {
    _app = app;
    if (_app) {
        self.appname.text = _app.appName;
        [_appIcon setImageWithURL:[Contants getImageUrl:_app.imagePath width:100 height:100]];
        _appSize.text = _app.size;
        _appVersion.text = _app.versionApp;
    }
}

- (IBAction)deleteDownload:(id)sender {
    [UIAlertView showWithTitle:@"Thông báo" message:[NSString stringWithFormat:@"Ban có muốn xoá file cài đặt game %@ không?", self.app?self.app.appName:@"này"] cancelButtonTitle:@"Có" otherButtonTitles:@[@"Không"] tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
        if (buttonIndex == 0) {
            [[DownloadManager sharedManager] removeAppFromList:self.app];
        }
    }];
}
@end
